package jpaperwork.web;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

/**
 * User: fleipold
 * Date: Nov 8, 2009
 * Time: 9:47:35 PM
 */
public class TemplateParserTest {

    @Test
    public void testA() {
        TemplateParser parser = new TemplateParser("/{x}/edit");
        assertEquals(3, parser.fragments.size());

        assertEquals(new TextFragment("/"), parser.fragments.get(0));
        assertEquals(new PlaceholderFragment("x"), parser.fragments.get(1));
        assertEquals(new TextFragment("/edit"), parser.fragments.get(2));
    }


    @Test
    public void testB() {
        TemplateParser parser = new TemplateParser("edit/{y}");
        assertEquals(2, parser.fragments.size());

        assertEquals(new TextFragment("edit/"), parser.fragments.get(0));
        assertEquals(new PlaceholderFragment("y"), parser.fragments.get(1));
    }

    @Test
    public void testC() {
        TemplateParser parser = new TemplateParser("edit/{y}/{z}");
        assertEquals(4, parser.fragments.size());

        assertEquals(new TextFragment("edit/"), parser.fragments.get(0));
        assertEquals(new PlaceholderFragment("y"), parser.fragments.get(1));
        assertEquals(new TextFragment("/"), parser.fragments.get(2));
        assertEquals(new PlaceholderFragment("z"), parser.fragments.get(3));
    }


    

}
